
import 'dart:io';
import 'dart:io' show Platform;
import 'package:flutter/material.dart';

/// 探鸽公共文件 - 返回判断
class PlatformUtil {
  PlatformUtil._privateConstructor();

  static bool ohos() {
    return Platform.operatingSystem == 'ohos';
  }

  static Widget autoUnfocus({required Widget child}) {
    return Builder(
      builder: (BuildContext context) {
        return WillPopScope(
          onWillPop: () async {
            if (FocusScope.of(context).hasFocus) {
              FocusScope.of(context).unfocus();
              return false;
            }
            return true;
          },
          child: child,
        );
      },
    );
  }

  static Widget filterPop({required Widget child}) {
    return Builder(
      builder: (BuildContext context) {
        return WillPopScope(
          onWillPop: () async {
            return false;
          },
          child: child,
        );
      },
    );
  }
}
